home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
726-750
/
745
/
arexxbox
/
rxif
/
rx_help.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-18
|
2KB
|
103 lines
void rx_help( struct RexxHost *host, struct rxd_help **rxd, long action )
{
struct rxd_help *rd = *rxd;
struct rxs_command *rxc;
int cnt = 1;
/*
* Dieser HELP-Befehl unterstützt (noch) nicht das PROMPT-Keyword
* da das nur im Rahmen eines GUIs Sinn hat
*/
switch( action )
{
case RXIF_INIT:
*rxd = calloc( sizeof *rd, 1 );
break;
case RXIF_ACTION:
/* Insert your code HERE */
if( rd->arg.prompt )
{
rd->rc = -10;
rd->rc2 = (long) "Prompt option not yet implemented";
return;
}
if( rd->arg.command )
{
rxc = FindRXCommand( rd->arg.command );
if( !rxc )
{
rd->rc = -10;
rd->rc2 = (long) "Unknown Command";
return;
}
if( rd->res.commanddesc = malloc( strlen(rxc->command)
+ strlen(rxc->args) + strlen(rxc->results) + 20 ) )
{
sprintf( rd->res.commanddesc,
"%s%c%s%s%s%s%s",
rxc->command,
(rxc->results || rxc->args) ? ' ' : '\0',
rxc->results ? "VAR/K,STEM/K" : "",
(rxc->results && rxc->args) ? "," : "",
rxc->args ? rxc->args : "",
rxc->results ? " => " : "",
rxc->results ? rxc->results : "" );
}
else
{
rd->rc = 10;
rd->rc2 = ERROR_NO_FREE_STORE;
return;
}
}
else
{
char **s;
rxc = rxs_commandlist;
while( rxc->command )
{
cnt++;
rxc++;
}
if( !(s = calloc( sizeof(char *), cnt )) )
{
rd->rc = 10;
rd->rc2 = ERROR_NO_FREE_STORE;
return;
}
rd->res.commandlist = s;
rxc = rxs_commandlist;
while( rxc->command )
{
*s = rxc->command;
s++;
rxc++;
}
}
break;
case RXIF_FREE:
/* FREE your local data HERE */
if( rd->res.commanddesc )
free( rd->res.commanddesc );
if( rd->res.commandlist )
free( rd->res.commandlist );
free( rd );
break;
}
return;
}